﻿// CUserCheckDlg.cpp: 实现文件
//

#include "pch.h"
#include "SP.h"
#include "CUserCheckDlg.h"
#include "afxdialogex.h"


// CUserCheckDlg 对话框

IMPLEMENT_DYNAMIC(CUserCheckDlg, CDialogEx)

CUserCheckDlg::CUserCheckDlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG_USER, pParent)
	, User(_T(""))
{

}

CUserCheckDlg::~CUserCheckDlg()
{
}

void CUserCheckDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT1, User);
}

BOOL CUserCheckDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	ReadConfigIni();
	return TRUE;
}

void CUserCheckDlg::ReadConfigIni()
{
	User = Manager.UserMsg;
	UpdateData(FALSE);
}

void CUserCheckDlg::SaveValueToConfig()
{
	UpdateData(TRUE);

	Manager.UserMsg = User;

	CString cstr;

	Manager.m_cLoginConfigIni.SaveConfigIni(L"Login", L"UserMsg", Manager.UserMsg);
	
	Manager.GetLog()->DisplayAndSaveLog(L"Login保存数据完成", LV_EVENT);
}

void CUserCheckDlg::OnCancel()
{
	CDialogEx::OnCancel();
}


BEGIN_MESSAGE_MAP(CUserCheckDlg, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON1, &CUserCheckDlg::OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON4, &CUserCheckDlg::OnBnClickedButton4)
END_MESSAGE_MAP()


// CUserCheckDlg 消息处理程序


void CUserCheckDlg::OnBnClickedButton1()
{
	// TODO: 在此添加控件通知处理程序代码
	SaveValueToConfig();
	CDialogEx::OnCancel();
}


void CUserCheckDlg::OnBnClickedButton4()
{
	// TODO: 在此添加控件通知处理程序代码
	CDialogEx::OnCancel();
}
